package com.atbeijing.bigdata.spark.core.rdd.operator.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark01_Oper_Transform_2 {

    def main(args: Array[String]): Unit = {

        val conf = new SparkConf().setMaster("local[*]").setAppName("TransformOperator")
        val sc = new SparkContext(conf)

        // TODO 从服务器日志数据apache.log中获取用户请求URL资源路径
        val rdd : RDD[String] = sc.textFile("data/apache.log")
        // 扁平化：一个整体拆分成一个一个的个体，所有的个体都要使用
        // long string(A) => short string(B)
        val urlRDD = rdd.map(
            line => {
                var datas = line.split(" ")
                datas(6)
            }
        )
        urlRDD.collect().foreach(println)

        sc.stop()

    }
}
